<?php
namespace wogu2\http;

use wogu2\stdlib\RequestInterface;

class Request implements RequestInterface
{
    private $_config = null;
    private $_properties = array();
    
    public function setConfig($config) {
        $this->_config = $config;
    }
    
    public function getParameter($name, $scopes = 'request') {
        $parameters = array(
            'get' => $_GET,
            'post' => $_POST,
            'cookie' => $_COOKIE,
            'request' => $_REQUEST
        );
        
        $scopes = is_array($scopes) ? $scopes : array($scopes);
        foreach($scopes as $scope) {
            $scopeParameters = $parameters[$scope];
            if(isset($scopeParameters[$name])) {
                return $scopeParameters[$name];
            }
        }
        
        return null;
    }
    
    public function getRealPath($path, $dir = 'appDir') {
        return $this->_config[$dir] . str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, trim($path, '/\\')) . DIRECTORY_SEPARATOR;
    }
}